//二叉树的后序遍历
#include <stdio.h>  
#include <stdlib.h>  
  
// 定义二叉树节点结构体  
struct TreeNode {  
    int val;  
    struct TreeNode *left;  
    struct TreeNode *right;  
};  
  
// 创建新节点的函数  
struct TreeNode* createNode(int val) {  
    struct TreeNode* node = (struct TreeNode*)malloc(sizeof(struct TreeNode));  
    node->val = val;  
    node->left = NULL;  
    node->right = NULL;  
    return node;  
}  
  
// 后序遍历函数  
void postorderTraversal(struct TreeNode* root) {  
    if (root == NULL) {  
        return;  
    }  
    postorderTraversal(root->left);  
    postorderTraversal(root->right);  
    printf("%d ", root->val);  
}  
  
int main() {  
    // 创建二叉树  
    struct TreeNode* root = createNode(1);  
    root->left = createNode(2);  
    root->right = createNode(3);  
    root->left->left = createNode(4);  
    root->left->right = createNode(5);  
    root->right->left = createNode(6);  
    root->right->right = createNode(7);  
  
    // 后序遍历二叉树并输出结果  
    printf("后序遍历结果：");  
    postorderTraversal(root);  
    printf("\n");  
  
    return 0;  
}